# -*- coding:utf-8 -*-
# Create by Zhou
# 2021/11/29/15:06
# May Saint Diana bless your coding!

from ANC_tools import *
import numpy as np
import matplotlib.pyplot as plt

if __name__ == '__main__':
    # 初级路径FIR模型
    primaryPathModel = np.array([0, 0, 0, 0, 0, 1, -0.3, 0.2])
    # 次级路径FIR模型
    secondaryPathModel = np.array([0, 0, 1, 0.5])
    # 构造声源
    x = np.random.normal(loc=0.0, scale=1, size=4800)  # 正态分布随机噪声
    # plt.plot(x)
    # plt.show()
    # 得到初级噪声
    Yp = FIR_Filter(x, primaryPathModel)
    error = FxLMS(x, Yp, 16, secondaryPathModel, 0.01)  # 调用FxLMS算法
    plt.plot(error)
    plt.show()

    plt.figure()
    plt.plot(ANR(Yp, error))
    plt.show()

